Pin Input
The PinInput
component in Pearl UI is a specialized input component optimized for entering sequences of digits quickly. It supports various sizes, variants, color schemes, and additional features like automatic focus management and input type restrictions. By default, it renders a sequence of 4 input fields with a medium size and filled variant.
#
Importimport { PinInput } from "pearl-ui";
#
Usage<PinInput onComplete={(pinValue) => console.log(pinValue)} />
#
Pin Input SizesUse the size
prop to change the size of the pin input fields. You can set the value to the keys available in
<PinInput size="xs" />
<PinInput size="s" />
<PinInput size="m" />
<PinInput size="l"/>
#
Pin Input VariantsThe variant
prop allows you to change the visual style of the pin input fields. The available variants are
<PinInput variant="filled" />
<PinInput variant="outline" />
#
Pin Input Color SchemesThe colorScheme
prop allows you to change the color palette of the pin input fields. The available color schemes are
<PinInput colorScheme="primary" />
<PinInput colorScheme="secondary" />
#
Auto Focus ManagementThe manageFocus
prop allows you to enable or disable automatic focus management. When enabled, focus will move automatically to the next input once the current input is filled.
<PinInput manageFocus placeholder="Pin input with auto focus management" />
#
Changing Input TypesThe type
prop allows you to restrict the type of values the pin-input should allow. The available types are
<PinInput type="number" />
<PinInput type="alphanumeric" />
#
Changing Number of Input FieldsThe numFields
prop allows you to specify the number of input fields in the pin input. By default, there are 4 input fields.
<PinInput numFields={6} />
#
Masking Input ValuesThe secureTextEntry
prop allows you to mask the input fields, useful for password-based pin inputs. When enabled, the input fields will display dots instead of the actual characters.
<PinInput secureTextEntry />
#
Overriding StylesThe PinInput
component supports a variety of style props which can be used to override the pre-defined variant style in the theme. Manual style props passed into the component have a higher precedence than the default component configuration.
// The marginTop prop adds a top margin to the pin input field// The backgroundColor prop overrides the default component config value of backgroundColor="neutral.200"<PinInput variant="filled" marginTop="3" backgroundColor="green" />
#
Example#
AccessibilityPinInput
has therole
oftext field
.- When
PinInput
is disabled, it is reflected asdisabled
in screen readers. PinInput
has the default accessibility label set as the placeholder value passed into it. A custom label can be specified using theaccessibilityLabel
prop.
#
Component Properties#
Supported Style PropertiesThe PinInput
component is a composition of the Input component, which means all Input props can be passed to it.
#
Additional PropertiesName | Required | Type | Default | Description |
---|---|---|---|---|
numFields | No | 4 | Determines the number of input fields in the pin input. | |
manageFocus | No | true | If set to true , focus will move automatically to the next input once filled. | |
type | No | "number" | The type of values the pin-input should allow. | |
onComplete | No | Function called when all inputs have valid values. |